EmergencyPlanForm=Ext.extend(Ext.Window,{
    constructor:function(a){
        Ext.apply(this,a);
        this.initUIComponents();
        EmergencyPlanForm.superclass.constructor.call(this,{
            id:'EmergencyPlanForm',
            title:'应急演练',
            layout:'fit',
            modal:true,
            items : yearGridFormPanel,
            buttons : yearGridFormButtons,
            iconCls : "menu-flowWait",
            width : 620,
            height : 375,
            buttonAlign:'center',
            buttonStyle:'padding:2px;'
        })
    },
    initUIComponents:function(){
        createyeargridform({
            operation:this,
            form:{
                saveUrl: __ctxPath+"/emergency/saveEmergencyPlan.do",
                items:[
                        {
                            id : "emergencyPlan.id",
                            name : "emergencyPlan.id",
                            xtype : "hidden",
                            value : this.id == null ? "": this.id
                        }, {
                            name : "emergencyPlan.years",
                            xtype : "hidden",
                            id : "emergencyPlan.years",
                            value : this.years == null ? "" : this.years
                        }, {
                            layout:'column',
                            bodyStyle:"padding:5px;",
                            border:false,
                            items:[{
                                layout:'form',
                                bodyStyle:'padding:5px;',
                                columnWidth:.5,
                                border:false,
                                items:[{
                                    xtype:'combo',
                                    fieldLabel:'所属机构',
                                    hiddenName:'emergencyPlan.institution',
                                    mode:'local',
                                    editable:false,
                                    width:146,
                                    triggerAction:'all',
                                    store:new Ext.data.ArrayStore({
                                        id:0,
                                        fields:['id','type'],
                                        data:[ [ "1", "组织部" ],
                                               [ "2", "财务部" ],
                                               [ "3", "销售部" ]]
                                    }),
                                    valueField:'type',
                                    displayField:'type',
                                    value:'销售部'
                                }]
                            },{
                                layout:'column',
                                bodyStyle:'padding:5px;',
                                columnWidth:.5,
                                border:false,
                                items:[{
                                    columnWidth:.7,
                                    layout:"form",
                                    border:false,
                                    items:[{
                                        xtype:"textfield",
                                        width:100,
                                        fieldLabel:'预案编号<font color="red">*</font>',
                                        name:'emergencyPlan.emergencyNo',
                                        allowBlank:false,
                                        readOnly:true,
                                        maxLength:100
                                    }]
                                },{
                                    columnWidth:.3,
                                    layout:"form",
                                    border:false,
                                    items:[{
                                        text:'选择',
                                        width:55,
                                        xtype:'button',
                                        handler:function(){
                                            SingleGridEject.getView({
                                                callback:function(records){
                                                    console.info(records[0].data);
                                                     var emergencyPlanForm=yearGridFormPanel.getForm();
                                                     emergencyPlanForm.findField("emergencyPlan.emergencyNo").setValue(records[0].data.emergencyNo);
                                                     emergencyPlanForm.findField("emergencyPlan.emergencyName").setValue(records[0].data.emergencyName);
                                                },
                                                multiSel:false,
                                                select:true,
                                                winId:'EmergencyExerciseInfoWin',
                                                winTitle:'应急预案信息查看',
                                                winWidth:700,
                                                winHeight:480,
                                                winListurl : __ctxPath + "/emergency/listEmergencyExercise.do",
                                                winFields : [ "id", 'years','institution','emergencyNo', "emergencyName", "emergencyKeyPlace", "coverPost","hazardSourceName","emergencyContactMode","rescueTeam"],
                                                columnModel :  [ {
                                                    header : "id",
                                                    dataIndex : "id",
                                                    hidden : true
                                                }, {
                                                    header : "年份",
                                                    dataIndex : "years",
                                                    width : 50,
                                                    hidden:false,
                                                    sortable : true
                                                }, {
                                                    header:"所属机构",
                                                    dataIndex:'institution',
                                                    width:100
                                                },{
                                                    header : "预案编号",
                                                    dataIndex : "emergencyNo",
                                                    width : 100
                                                }, {
                                                    header : "预案名称",
                                                    dataIndex : "emergencyName",
                                                    width : 70
                                                }, {
                                                    header : "关键场所",
                                                    dataIndex : "emergencyKeyPlace",
                                                    width : 100
                                                }, {
                                                    header:"覆盖岗位",
                                                    dataIndex:"coverPost",
                                                    width:100
                                                }, {
                                                    header : "危险源名称",
                                                    dataIndex : "hazardSourceName",
                                                    width : 70
                                                },{
                                                    header:'应急联系方式',
                                                    dataIndex:'emergencyContactMode',
                                                    width:70
                                                },{
                                                    header:'救援队伍',
                                                    dataIndex:'rescueTeam',
                                                    width:70
                                                }]
                                            }).show();
                                        }
                                    }]
                                }]
                            },{
                                layout:"form",
                                bodyStyle:'padding:5px;',
                                border:false,
                                columnWidth:.5,
                                items:[{
                                    xtype:'textfield',
                                    fieldLabel:'预案名称',
                                    name:'emergencyPlan.emergencyName',
                                    readOnly:true,
                                    width:146,
                                    maxLength:200
                                }]
                            },{
                                layout:'form',
                                bodyStyle:'padding:5px;',
                                border:false,
                                columnWidth:.5,
                                items:[{
                                    xtype:'textfield',
                                    fieldLabel:'演练主题<font color=\'red\'>*</font>',
                                    name:'emergencyPlan.exerciseTheme',
                                    width:146,
                                    allowBlank:false,
                                    maxLength:200
                                }]
                            },{
                                layout:'form',
                                bodyStyle:'padding:5px;',
                                border:false,
                                columnWidth:.5,
                                items:[{
                                    xtype:'textfield',
                                    name:'emergencyPlan.exerciseMode',
                                    fieldLabel:'演练方式',
                                    width:146,
                                    maxLength:100
                                }]
                            },{
                                layout:'form',
                                bodyStyle:'padding:5px;',
                                border:false,
                                columnWidth:.5,
                                items:[{
                                    xtype:'datefield',
                                    format:'y-d-m',
                                    blankText:'演练时间不能为空！',
                                    name:'emergencyPlan.exerciseTimeDate',
                                    fieldLabel:'演练时间',
                                    width:146
                                }]
                            },{
                                layout:'form',
                                bodyStyle:'padding:5px;',
                                border:false,
                                columnWidth:.5,
                                items:[{
                                    xtype:'numberfield',
                                    name:'emergencyPlan.exerciseFunds',
                                    fieldLabel:'演练经费<font color="red">*</font>',
                                    allowBlank:false,
                                    width:146,
                                    nanText:'请输入数字!'
                                }]
                            },{
                                layout:'form',
                                bodyStyle:'padding:5px;',
                                border:false,
                                columnWidth:.5,
                                items:[{
                                    xtype:'textfield',
                                    name:'emergencyPlan.exerciseOrgainzer',
                                    fieldLabel:'演练组织者',
                                    width:146
                                }]
                            }]
                        },{
                            layout:'column',
                            bodyStyle:'padding:5px;',
                            border:false,
                            columnWidth:1.,
                            items:[{
                                layout:'form',
                                bodyStyle:'padding:5px;',
                                border:false,
                                items:[{
                                    xtype:'textfield',
                                    name:'emergencyPlan.exercisePlance',
                                    fieldLabel:'演练地点',
                                    width:435
                                }]
                            }]
                        },{
                            layout:'column',
                            bodyStyle:"padding:5px;",
                            border:false,
                            items:[{
                                layout:'form',
                                bodyStyle:"padding:5px;",
                                columnWidth:1.,
                                items:[{
                                    xtype:'textarea',
                                    fieldLabel:'演练内容',
                                    name:'emergencyPlan.exerciseContent',
                                    width:448,
                                    maxLength:1000
                                }]
                            }]
                        },{
                           layout:'column',
                           bodyStyle:"padding:5px;",
                           border:false,
                           items:[{
                               layout:"form",
                               bodyStyle:"padding:5px;",
                               columnWidth:1.,
                               items:[{
                               xtype:"textarea", 
                               fieldLabel: '演练人员', 
                               name: 'emergencyPlan.exercisePeople', 
                               width : 448,
                               maxLength:2000
                               }]
                           }]
                       },{
                           layout:'column',
                           bodyStyle:"padding:5px;",
                           border:false,
                           items:[{
                               layout:'form',
                               bodyStyle:"padding:5px;",
                               columnWidth:1.,
                               items:[{
                               xtype:'textarea',
                               fieldLabel:'备注',
                               name:'emergencyPlan.remark',
                               width:448,
                               maxLength:1000
                               }]
                           }]
                       }
               ]
            },
            loadData:{
                getUrl:__ctxPath +"/emergency/getEmergencyPlan.do",
                preName : "emergencyPlan"
            }
        });
    }
});